import {UserActions} from './user';

const initialState = {
  desc: '',
  perms: [],
};

export const RoleDetailActions = {
  ROLE_DETAIL_UPDATE: 'role_detail_update',
};

export function updateRoleDetail(payload) {
  return {
    type: RoleDetailActions.ROLE_DETAIL_UPDATE,
    payload,
  };
}

export default function roleDetail(state = initialState, action) {
  switch (action.type) {
    case RoleDetailActions.ROLE_DETAIL_UPDATE:
      return {...state, ...action.payload};
    case UserActions.USER_SIGN_OUT:
      return {
        count: 0,
        current: 0,
        total: 0,
        results: [],
      };
    default:
      return state;
  }
}
